Skip to content

fix(agents): accept generation kwargs on LlmAgent - #6837

Open
a2105z wants to merge 1 commit into
google:mainfrom
a2105z:fix/llm-agent-generation-kwargs
Open

fix(agents): accept generation kwargs on LlmAgent#6837
a2105z wants to merge 1 commit into
google:mainfrom
a2105z:fix/llm-agent-generation-kwargs

Conversation

@a2105z

@a2105z a2105z commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • LlmAgent(temperature=0.1) (and other GenerateContentConfig knobs such as top_p and max_output_tokens) now folds into generate_content_config instead of failing with extra_forbidden.
  • Reserved knobs that already have an agent field (system_instruction, response_schema) raise a message that points at instruction= / output_schema=; setting the same field both as a kwarg and inside generate_content_config is rejected.
  • The LlmAgent class and generate_content_config field docstrings now document the mapping.

Closes: #6836

Test plan

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Unit Tests:

uv run python -m pytest tests/unittests/agents/test_llm_agent_fields.py tests/unittests/agents/test_llm_agent_error_messages.py -q
107 passed

Covers the original crash (temperature= with output_schema), merging with an existing generate_content_config, camelCase aliases, thinking_config kwargs, reserved-field redirects, conflicts, and unknown extras remaining forbidden.

Manual End-to-End (E2E) Tests:

from google.adk.agents import LlmAgent
from pydantic import BaseModel

class MySchema(BaseModel):
    score: int

agent = LlmAgent(
    name="grader",
    model="gemini-3.5-flash-lite",
    instruction="Grade the exam.",
    output_schema=MySchema,
    temperature=0.1,
)
assert agent.generate_content_config.temperature == 0.1

Previously this raised ValidationError: temperature Extra inputs are not permitted.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.

@google-cla

google-cla Bot commented Aug 20, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Users coming from google-genai pass temperature= (and similar knobs) on
LlmAgent, which failed with extra_forbidden and no pointer to
generate_content_config. Fold GenerateContentConfig fields into that
config, and point reserved fields at the LlmAgent argument that owns them.

Fixes google#6836
@a2105z
a2105z force-pushed the fix/llm-agent-generation-kwargs branch from 8fe8946 to 9c94f11 Compare August 20, 2026 20:54
@a2105z

a2105z commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

@googlebot I fixed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LlmAgent rejects temperature= with extra_forbidden — no discoverable path to generate_content_config

2 participants